package com.project.poetry.service.controller;

import com.alibaba.fastjson.JSON;
import com.project.poetry.service.service.WebService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import java.io.*;
import java.util.List;

/**
 * web控制器
 * 这里使用ModelAndView实现跳转页面并携带数据。其实不建议
 * 使用ModelAndView携带数据，这里只是写个demo，说明可以使
 * 用这种方式。
 * 这里对应的前端页面使用了thymeleaf技术。也是当作demo作为
 * 参考。
 * @author mengxj
 */
@Api("web")
@Controller
@RequestMapping("web")
public class WebController {

    @Resource
    private WebService webService;

    @ApiOperation("保存诗词页面")
    @GetMapping("savePoetryPage")
    public ModelAndView savePoetryPage(@RequestParam(value = "poetryId", required = false) Long poetryId){
        return this.webService.savePoetryPage(poetryId);
    }

   // @Scheduled(cron = "* * 17 * * ?")
    public void s(){
        System.out.println("=========");
    }
}
